# -*- coding: utf-8 -*-
# Calculation Library

DVALUE = ["0", "0"]

import gettext
gettext.install("gfh-tool", unicode=1)

#Math module is needed because of pi.
from math import pi
from math import sqrt


# - Square : [tr] Kare ----------------------
# | -> Periphery : [tr] Çevre
# | --| a*4
# | -> Area : [tr] Alan
# | --| a**2

class Square:
    def __init__(self, a):
        self.a = a
    def periphery(self):
        return (self.a*4)
    def area(self):
        return (self.a**2)
    def return_SVG(self):
        sq = """<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg width="100%" height="100%" version="1.1"
xmlns="http://www.w3.org/2000/svg">

<rect x=\"""" + DVALUE[0] + """\"  y=\"""" + DVALUE[1] +  """\" width=\"""" + str(self.a) + """\" height=\"""" + str(self.a) +"""\"
style="fill:white;stroke:black;stroke-width:2;
opacity:0.9"/>

</svg> """ 
        return sq

# - Circle : [tr] Daire ----------------------
# | -> Periphery : [tr] Çevre
# | --| 2*pi*r
# | -> Area : [tr] Alan
# | --| pi*(r**2)

class Circle:
    def __init__(self, a):
        self.a = a
    def periphery(self):
        return (2*self.a*pi)
    def area(self):
        return (pi*(self.a**2))
    def return_SVG(self):
        circ = """<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg >

<svg width="100%" height="100%" version="1.1"
xmlns="http://www.w3.org/2000/svg">
i
<circle cx=\"""" + '50' + """\"  cy=\"""" + '50' +  """\" r=\"""" + str(self.a/2) + """\" style="fill:
white;stroke:black;stroke-width:2;
opacity:0.9"/>
</svg>  """
        return circ

# - Rectangle : [tr] Dikdörtgen ----------------------
# | -> Periphery : [tr] Çevre
# | --| 2*(l+b)
# | -> Area : [tr] Alan
# | --| l*b

class Rectangle:
    def __init__(self, l, b):
        self.l = l
        self.b = b
    def periphery(self):
        return (2*(self.l + self.b))
    def area(self):
        return (self.l*self.b)
    def return_SVG(self):
        rect = """<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg width="100%" height="100%" version="1.1"
xmlns="http://www.w3.org/2000/svg">

<rect x=\"""" + DVALUE[0] + """\"  y=\"""" + DVALUE[1] +  """\" width=\"""" + str(self.l) + """\" height=\"""" + str(self.b) + """\"
style="fill:white;stroke:black;stroke-width:2;
opacity:0.9"/>

</svg> """
        return rect

# - Cube : [tr] Küp ----------------------
# | -> Cross Sectional Area : [tr] Kesit Alanı
# | --| a**2 
# | -> Surface Area : [tr] Yüzey Alanı
# | --| 6*(a**2)
# | -> Volume : [tr] Hacim
# | --| a**3
# | -> Cross Sectional Area/Volume 
# | --| 1/a
# | -> Surface Area/Volume
# | --| 6/a

class Cube:
    def __init__(self, a):
        self.a = a
    def CroSecArea(self):
        return (self.a**2)
    def SurfArea(self):
        return (6*(self.a**2))
    def Volume(self):
        return (self.a**3)
    def CroSecAreaDivVol(self):
        return (1/float(self.a))
    def SurfAreaDivVol(self):
        return (6/float(self.a))
    def return_SVG(self):
        cube = """<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
    "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink" >

<image x=\"""" + DVALUE[0] + """\"  y=\"""" + DVALUE[1] +  """\" width=\"""" + str(self.a*2.5) + """\" height=\"""" + str(self.a*3) + """\" xlink:href="cube.svg" />
	 
	 <!-- SVG code goes here -->

</svg>  """

        return cube

# - Sphere : [tr] Küre ----------------------
# | -> Cross Sectional Area : [tr] Kesit Alanı
# | --| (r**2)*pi 
# | -> Surface Area : [tr] Yüzey Alanı
# | --| 4*(r**2)*pi 
# | -> Volume : [tr] Hacim
# | --| 4/3*((r**3)*pi
# | -> Cross Sectional Area/Volume 
# | --| 3/(4*r)
# | -> Surface Area/Volume
# | --| 3/r

class Sphere:
    def __init__(self, a):
        self.a= a
    def CroSecArea(self):
        return (4*(float(self.a)**2)*pi)
    def SurfArea(self):
        return ( 4*(float(self.a)**2)*pi )
    def Volume(self):
        return ((4/3)*(float(self.a)**3)*pi)
    def CroSecAreaDivVol(self):
        return (3/(4*float(self.a)))
    def SurfAreaDivVol(self):
        return (3/float(self.a))
    def return_SVG(self):
        sph="""<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
    "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink" >

<image x=\"""" + DVALUE[0] + """\"  y=\"""" + DVALUE[1] +  """\" width=\"""" + str(self.a*2) + """\" height=\"""" + str(self.a*3) + """\" xlink:href="sphere.svg" />
	 
	 <!-- SVG code goes here -->

</svg> """

        return sph

# - Cylinder : [tr] Silindir ----------------------
# | -> Cross Sectional Area : [tr] Kesit Alanı
# | --| (r**2)*pi 
# | -> Surface Area : [tr] Yüzey Alanı
# | --| 2*(pi*r*h + pi*(r**2))
# | -> Volume : [tr] Hacim
# | --| pi*(r**2)*h
# | -> Cross Sectional Area/Volume 
# | --| 1/h
# | -> Surface Area/Volume
# | --| 2*(h+r) / (r*h)

class Cylinder:
    def __init__(self, a, h):
        self.a = a
        self.h = h
    def CroSecArea(self):
        return ((float(self.a)**2)*pi) 
    def SurfArea(self):
        return (2*(pi*float(self.a)*float(self.h) + pi*(float(self.a)**2)))
    def Volume(self):
        return (pi*(float(self.a)**2)*float(self.h))
    def CroSecAreaDivVol(self):
        return (1/float(self.h))
    def SurfAreaDivVol(self):
        return (2*(float(self.h)+float(self.a)) / (float(self.a)*float(self.h)))
    def return_SVG(self):
        cyl="""<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
    "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink" >

<image x=\"""" + DVALUE[0] + """\"  y=\"""" + DVALUE[1] +  """\" width=\"""" + str(self.a*4) + """\" height=\"""" + str(self.h*3.5) + """\" xlink:href="cylinder.svg" />
	 
	 <!-- SVG code goes here -->

</svg> """

        return cyl

# - Rectangular Prism [tr] Dikdörtgenler Prizması ----------------------
# | -> Cross Sectional Area : [tr] Kesit Alanı
# | --| l*b 
# | -> Surface Area : [tr] Yüzey Alanı
# | --| 2*(l*b + h*b + l*h)
# | -> Volume : [tr] Hacim
# | --| l*h*b
# | -> Cross Sectional Area/Volume 
# | --| 1/h
# | -> Surface Area/Volume
# | --|2*(l*b + h*b + l*h) / (l*h*b)

class RectanPrism:
    def __init__(self, l, b, h):
        self.l = l
        self.b = b
        self.h = h
    def CroSecArea(self):
        return (l*b) 
    def SurfArea(self):
        return  (2*(self.l*self.b + self.h*self.b + self.l*self.h))
    def Volume(self):
        return (self.l * self.h * self.b)
    def CroSecAreaDivVol(self):
        return (1/self.h)
    def SurfAreaDivVol(self):
        return (2*(sefl.l*self.b + self.h*self.b + self.l*self.h) / (self.l*self.h*self.b))
    def return_SVG(self):
        recpr="""<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
    "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink" >

<image x=\"""" + DVALUE[0] + """\"  y=\"""" + DVALUE[1] +  """\" width=\"""" + str(self.a*2) + """\" height=\"""" + str(self.a*2) + """\" xlink:href="sphere.png" />
	 
	 <!-- SVG code goes here -->

</svg> """

        return recpr

# - Cone [tr] Koni ----------------------
# | -> Surface Area : [tr] Yüzey Alanı
# | --| pi*r*sqrt((h**2)+(r**2))
# | -> Volume : [tr] Hacim
# | --| 1/3*pi*(r**2)*h
# | -> Surface Area/Volume
# | --| pi*r*sqrt((h**2)+(r**2)) / 1/3*pi*(r**2)*h
# | -> Total Area : [tr] Toplam Alanı		
# | --| pi*r*(sqrt((h**2)+(r**2))+r)	

